import os

import yaml


class ReadYaml:

    @staticmethod
    def read_yaml(fileName):
        # mac版
        filePath = f"{os.path.abspath(os.path.dirname(os.path.dirname(__file__)))}/data/{fileName}"
        # win版
        # filePath = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + "\\data" + "\\" + fileName
        with open(filePath, 'r', encoding='utf-8') as f:
            data = yaml.safe_load(f)
        return data


if __name__ == '__main__':
    # data = ReadYaml.read_yaml('testdata01.yml')
    # print(data)
    # print(f"名称为：{data['class']}")
    data = ReadYaml.read_yaml('testdata02.yml')
    print(data)
